package com.tree.service.impl;

import com.tree.dao.TreeNewDao;
import com.tree.entity.TreeNew;
import com.tree.service.TreeNewService;
import com.tree.util.PageCal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

@Service
public class TreeNewServiceImpl implements TreeNewService {

    @Autowired
    private TreeNewDao treeNewDao;
    //分页查找新闻
    @Override
    public List<TreeNew> queryAll(int pageIndex, int rowSize) {

        List<TreeNew> list = new ArrayList<>();
        //将页数转换为行数
        int rowIndex = PageCal.calculateRowIndex(pageIndex,rowSize);
        list = treeNewDao.queryAll(rowIndex,rowSize);
        return list;
    }

    @Override
    public List<TreeNew> querySearch(String title) {
        return treeNewDao.querySearch(title);
    }
}
